package avicit.im.lantop.docmanager.deptdocarrange.service.api;


import avicit.platform6.core.rest.msg.ResponseMsg;
import avicit.platform6.core.restclient.RestClient;
import avicit.platform6.core.restclient.RestClientUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class DeptdocarrangeServiceApi {


    /**
     * 服务编码
     */
    private static final String SERVICE_CODE = "filebasicmanager";

    private static final String BASE_PATH = "/api/avicit/im/lantop/docmanager/deptdocarrange/action/rest/DeptdocarrangeServiceRest";

    @Autowired
    private RestClient restClient;


    /**
     * 通过数据id获得附件id
     * @param id
     * @return
     */
    public List<Map<String, Object>> getSourceNames(String id) {
        String url = BASE_PATH + "/getSourceNames";
        ResponseMsg<List<Map<String, Object>>> responseMsg = restClient.doPost(SERVICE_CODE, url, id, new ParameterizedTypeReference<ResponseMsg<List<Map<String, Object>>>>() {
        });
        return RestClientUtils.getResponseBody(responseMsg);
    }

    /**
     * 删除字段对应设置
     * @param id
     * @return
     */
    public List<Map<String, Object>> getSourceName(String id) {
        String url = BASE_PATH + "/getSourceName";
        ResponseMsg<List<Map<String, Object>>> responseMsg = restClient.doPost(SERVICE_CODE, url, id, new ParameterizedTypeReference<ResponseMsg<List<Map<String, Object>>>>() {
        });
        return RestClientUtils.getResponseBody(responseMsg);
    }
}
